/**
        Author: SpringHack - springhack@live.cn
        Last modified: 2017-02-09 21:37:38
        Filename: signer.js
        Description: Created by SpringHack using vim automatically.
**/
import NodeRSA from 'node-rsa';
import config from './config.js';

export default class {

    constructor(PrivateKey) {
        this.PrivateKey = PrivateKey;
        this.signingScheme = config.SIGNINGSCHEME;
        this.pk = new NodeRSA(this.PrivateKey);
        if (this.pk.isEmpty()) throw new Error(" pk not found!");
        this.pk.setOptions({signingScheme : this.signingScheme});
    }

    sign(message) {
        return this.pk.sign(message, 'hex');
    }

}
